add failing test for unsubscribe using wrong handler

This commit is contained in:
Bruno Windels 2019-07-29 10:58:27 +02:00
parent 9b94c4bb61
commit 0cf7cb36c4

View file

@ -30,3 +30,26 @@ export default class BaseObservableCollection {
// Add iterator over handlers here // Add iterator over handlers here
} }
export function tests() {
class Collection extends BaseObservableCollection {
constructor() {
super();
this.firstSubscribeCalls = 0;
this.firstUnsubscribeCalls = 0;
}
onSubscribeFirst() { this.firstSubscribeCalls += 1; }
onUnsubscribeLast() { this.firstUnsubscribeCalls += 1; }
}
return {
test_unsubscribe(assert) {
const c = new Collection();
const subscription = c.subscribe({});
// unsubscribe
subscription();
assert.equal(c.firstSubscribeCalls, 1);
assert.equal(c.firstUnsubscribeCalls, 1);
}
}
}