import { StageComponent } from "aurelia-testing"; import { bootstrap } from "aurelia-bootstrapper"; describe("the Aurelia Materialize CSS IconElement", () => { let sut; beforeEach(() => sut = StageComponent .withResources("./../../../../base/dist/amd/components/icon/iconElement") .inView("")); afterEach(() => sut.dispose()); it("must add the class 'material-icons' to the given element on attached", done => // arrange sut.manuallyHandleLifecycle() .create(bootstrap) .then(() => sut.bind()) .then(() => sut.viewModel.element = sut.element) // act .then(() => sut.attached()) // assert .then(() => expect(sut.element.classList).toContain("material-icons")) .then(done)); it("must remove the class 'material-icons' from the given element on detached", done => // arrange sut .manuallyHandleLifecycle() .create(bootstrap) .then(() => sut.bind()) .then(() => sut.viewModel.element = sut.element) .then(() => sut.attached()) .then(() => expect(sut.element.classList).toContain("material-icons")) // act .then(() => sut.detached()) // assert .then(() => expect(sut.element.classList).not.toContain("material-icons")) .then(done)); it("must add the size property as css class to the given element on attached", done => // arrange sut.inView("") .manuallyHandleLifecycle() .create(bootstrap) .then(() => sut.bind()) .then(() => sut.viewModel.element = sut.element) // act .then(() => sut.attached()) // assert .then(() => expect(sut.element.classList).toContain("large")) .then(done)); it("must remove the size property as css class the given element on detached", done => // arrange sut.inView("") .manuallyHandleLifecycle() .create(bootstrap) .then(() => sut.bind()) .then(() => sut.viewModel.element = sut.element) .then(() => sut.attached()) .then(() => expect(sut.element.classList).toContain("large")) // act .then(() => sut.detached()) // assert .then(() => expect(sut.element.classList).not.toContain("large")) .then(done)); });