Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('works', async function() {
// given
const deferred = pDefer();
function onError(error) {
deferred.resolve(error);
}
const {
app
} = createApp({ onError }, mount);
await app.createDiagram();
const tabInstance = app.tabRef.current;
const error = new Error('YZO!');
// when
if (!Number.isInteger(runOnChildTask) || runOnChildTask < 1) {
throw new Error(`createTask: runOnChildTask must be an integer >= 1`);
}
const tStatus = registry.get(id);
if (tStatus) {
if (!tStatus.adoptable) throw new Error(`Task ${id} has already been created`);
return;
} else {
const newStatus = {
id,
event: TaskState.Created,
status: undefined,
adoptable,
dPromise: pDefer(),
settled: false,
childTasksNeeded: runOnChildTask,
trivial,
};
// Record when the promise has been settled
const settled = () => newStatus.settled = true;
newStatus.dPromise.promise.then(settled, settled);
registry.set(id, newStatus);
}
if (trivial && !debugTrivial.enabled) return;
const returnHolder: Holder = {};
constructor(props) {
super(props);
this.state = {
...INITIAL_STATE,
tabShown: pDefer()
};
this.tabComponentCache = {};
// TODO(nikku): make state
this.navigationHistory = new History();
this.events = new EventEmitter();
// TODO(nikku): make state
this.closedTabs = new History();
this.tabRef = React.createRef();
const userPlugins = this.getPlugins('client');
private async getInfo() {
if (this.info_) return this.info_;
const deferred = pDefer();
this.waiters.push(deferred);
if (this.waiters.length === 1) {
return startTestMinikube().then((mkinfo) => {
this.info_ = mkinfo;
while (true) {
const waiter = this.waiters.pop();
if (!waiter) break;
waiter.resolve(this.info_);
}
return this.info_;
});
}
return deferred.promise;
}
return new Promise((resolve, reject) => {
const releaseComplete = pDefer();
this.locks.acquire("thelock",
(releaseLock) => {
resolve({
release: async () => {
releaseLock();
return releaseComplete.promise;
},
[$serverLock]: true,
});
},
(err) => {
if (err) {
reject(err);
releaseComplete.reject(err);
} else {
tabShown
} = this.state;
if (activeTab === tab) {
return tabShown.promise;
}
if (!this.isEmptyTab(tab)) {
const navigationHistory = this.navigationHistory;
if (navigationHistory.get() !== tab) {
navigationHistory.push(tab);
}
}
const deferred = pDefer();
this.setState({
activeTab: tab,
Tab: this.getTabComponent(tab),
tabShown: deferred,
tabState: {},
tabLoadingState: 'loading'
});
return deferred.promise;
}