/
githubmirror
/
meteor
Обзор
Документация
Войти
/
githubmirror
/
meteor
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
devel
packages/github-oauth/github-oauth_tests.js
34 строки
1 KB
Nacho Codoñer
use better naming
09 май 2024, 17:19
09 май 2024, 17:19
44b0a25
Код
Авторство
О чём код?
Tinytest.addAsync( 'github-oauth - run service oauth with mocked flow as expected', async function (test) { const oauthMock = mockBehaviours(OAuth, { _fetch: () => Promise.resolve({ json: () => ([{ access_token: 'testToken', email: { primary: 'email' } }])}), }); const service = 'github'; const serviceMockConfig = { service }; const mockConfig = { clientId: "test", secret: "test", loginStyle: "popup" }; if (Meteor.isServer) { await ServiceConfiguration.configurations.upsertAsync(serviceMockConfig, { $set: mockConfig }); const result = await OAuthTest.registeredServices[service].handleOauthRequest({}); test.isTrue(!!result?.serviceData, 'should return mocked result'); test.equal( oauthMock.mockedRuns.map(({ name }) => name), ['_redirectUri','_fetch','_fetch','_fetch','sealSecret'], 'should run mock oauth behaviors', ); } else if (Meteor.isClient) { ServiceConfiguration.configurations.insert({ ...serviceMockConfig, ...mockConfig }); Github.requestCredential({}); test.equal( oauthMock.mockedRuns.map(({ name }) => name), ['_loginStyle', '_redirectUri', '_stateParam', 'launchLogin'], 'should run mock oauth behaviors', ); } oauthMock.stop(); return Promise.resolve(); }, );