MCPcopy
hub / github.com/tc39/proposal-observable / "Returns a subscription object"

Function "Returns a subscription object"

test/subscribe.js:127–163  ·  view source on GitHub ↗
(test, { Observable })

Source from the content-addressed store, hash-verified

125 },
126
127 "Returns a subscription object" (test, { Observable }) {
128
129 let called = 0;
130 let subscription = new Observable(observer => {
131 return _=> called++;
132 }).subscribe({});
133
134 let proto = Object.getPrototypeOf(subscription);
135
136 testMethodProperty(test, proto, "unsubscribe", {
137 configurable: true,
138 writable: true,
139 length: 0,
140 });
141
142 testMethodProperty(test, proto, "closed", {
143 get: true,
144 configurable: true,
145 writable: true,
146 length: 0,
147 });
148
149 test
150 ._("Subscribe returns an object")
151 .equals(typeof subscription, "object")
152 ._("Contructor property is Object")
153 .equals(subscription.constructor, Object)
154 ._("closed property returns false before unsubscription")
155 .equals(subscription.closed, false)
156 ._("Unsubscribe returns undefined")
157 .equals(subscription.unsubscribe(), undefined)
158 ._("Unsubscribe calls the cleanup function")
159 .equals(called, 1)
160 ._("closed property is true after calling unsubscribe")
161 .equals(subscription.closed, true)
162 ;
163 },
164
165 "Cleanup function" (test, { Observable }) {
166

Callers

nothing calls this directly

Calls 2

testMethodPropertyFunction · 0.90
subscribeMethod · 0.80

Tested by

no test coverage detected