I'm trying to write a unit test for a class in my Aurelia app, as follows:
describe("MyClass", () => {
let sut;
beforeEach(() => {
sut = new MyClass(new S1(), new S2());
});
it(('should have default value') => {
expect(sut.getValue()).toBe('default');
expect(sut.getValue()).not.toBe('something else');
});
it('should set new value', () => {
let val = 'stack';
sut.setValue(val);
expect(let.getValue()).toBe(stack);
expect(let.getValue()).not.toBe('default');
});
it('should not set invalid value', () => {
let invalidVal = 'invalid value';
sut.setValue(invalidVal);
expect(sut.getValue()).toBe('default');
expect(sut.getValue()).not.toBe(invalidVal);
});
});
The test fails at 'should not set invalid value' - where expected 'stack' to be 'default'.
Aucun commentaire:
Enregistrer un commentaire