diff options
author | Mike Greiling <mike@pixelcog.com> | 2018-10-17 02:13:26 -0500 |
---|---|---|
committer | Mike Greiling <mike@pixelcog.com> | 2018-10-17 11:18:17 -0500 |
commit | f666026d71ebefd70219d5078b1f0c83fa01f84d (patch) | |
tree | ce43feb99c12c21dd266d25de24b1768bac1d459 /spec/javascripts/u2f | |
parent | 5a6fffcffca3dc8e4f52c90d3d18eaefd9e48aef (diff) | |
download | gitlab-ce-f666026d71ebefd70219d5078b1f0c83fa01f84d.tar.gz |
Prettify all spec files
Diffstat (limited to 'spec/javascripts/u2f')
-rw-r--r-- | spec/javascripts/u2f/authenticate_spec.js | 30 | ||||
-rw-r--r-- | spec/javascripts/u2f/mock_u2f_device.js | 12 | ||||
-rw-r--r-- | spec/javascripts/u2f/register_spec.js | 11 | ||||
-rw-r--r-- | spec/javascripts/u2f/util_spec.js | 24 |
4 files changed, 49 insertions, 28 deletions
diff --git a/spec/javascripts/u2f/authenticate_spec.js b/spec/javascripts/u2f/authenticate_spec.js index abe28f28dca..ddb09811dda 100644 --- a/spec/javascripts/u2f/authenticate_spec.js +++ b/spec/javascripts/u2f/authenticate_spec.js @@ -3,7 +3,7 @@ import U2FAuthenticate from '~/u2f/authenticate'; import 'vendor/u2f'; import MockU2FDevice from './mock_u2f_device'; -describe('U2FAuthenticate', function () { +describe('U2FAuthenticate', function() { preloadFixtures('u2f/authenticate.html.raw'); beforeEach(() => { @@ -32,21 +32,27 @@ describe('U2FAuthenticate', function () { window.u2f = this.oldu2f; }); - it('falls back to normal 2fa', (done) => { - this.component.start().then(() => { - expect(this.component.switchToFallbackUI).toHaveBeenCalled(); - done(); - }).catch(done.fail); + it('falls back to normal 2fa', done => { + this.component + .start() + .then(() => { + expect(this.component.switchToFallbackUI).toHaveBeenCalled(); + done(); + }) + .catch(done.fail); }); }); describe('with u2f available', () => { - beforeEach((done) => { + beforeEach(done => { // bypass automatic form submission within renderAuthenticated spyOn(this.component, 'renderAuthenticated').and.returnValue(true); this.u2fDevice = new MockU2FDevice(); - this.component.start().then(done).catch(done.fail); + this.component + .start() + .then(done) + .catch(done.fail); }); it('allows authenticating via a U2F device', () => { @@ -57,7 +63,9 @@ describe('U2FAuthenticate', function () { deviceData: 'this is data from the device', }); - expect(this.component.renderAuthenticated).toHaveBeenCalledWith('{"deviceData":"this is data from the device"}'); + expect(this.component.renderAuthenticated).toHaveBeenCalledWith( + '{"deviceData":"this is data from the device"}', + ); }); describe('errors', () => { @@ -85,7 +93,9 @@ describe('U2FAuthenticate', function () { deviceData: 'this is data from the device', }); - expect(this.component.renderAuthenticated).toHaveBeenCalledWith('{"deviceData":"this is data from the device"}'); + expect(this.component.renderAuthenticated).toHaveBeenCalledWith( + '{"deviceData":"this is data from the device"}', + ); }); }); }); diff --git a/spec/javascripts/u2f/mock_u2f_device.js b/spec/javascripts/u2f/mock_u2f_device.js index a8692be3546..26ddd8ade61 100644 --- a/spec/javascripts/u2f/mock_u2f_device.js +++ b/spec/javascripts/u2f/mock_u2f_device.js @@ -5,14 +5,14 @@ export default class MockU2FDevice { this.respondToAuthenticateRequest = this.respondToAuthenticateRequest.bind(this); this.respondToRegisterRequest = this.respondToRegisterRequest.bind(this); window.u2f || (window.u2f = {}); - window.u2f.register = (function (_this) { - return function (appId, registerRequests, signRequests, callback) { - return _this.registerCallback = callback; + window.u2f.register = (function(_this) { + return function(appId, registerRequests, signRequests, callback) { + return (_this.registerCallback = callback); }; })(this); - window.u2f.sign = (function (_this) { - return function (appId, challenges, signRequests, callback) { - return _this.authenticateCallback = callback; + window.u2f.sign = (function(_this) { + return function(appId, challenges, signRequests, callback) { + return (_this.authenticateCallback = callback); }; })(this); } diff --git a/spec/javascripts/u2f/register_spec.js b/spec/javascripts/u2f/register_spec.js index 4d90a3ccce6..261db3d66d7 100644 --- a/spec/javascripts/u2f/register_spec.js +++ b/spec/javascripts/u2f/register_spec.js @@ -3,15 +3,18 @@ import U2FRegister from '~/u2f/register'; import 'vendor/u2f'; import MockU2FDevice from './mock_u2f_device'; -describe('U2FRegister', function () { +describe('U2FRegister', function() { preloadFixtures('u2f/register.html.raw'); - beforeEach((done) => { + beforeEach(done => { loadFixtures('u2f/register.html.raw'); this.u2fDevice = new MockU2FDevice(); this.container = $('#js-register-u2f'); this.component = new U2FRegister(this.container, $('#js-register-u2f-templates'), {}, 'token'); - this.component.start().then(done).catch(done.fail); + this.component + .start() + .then(done) + .catch(done.fail); }); it('allows registering a U2F device', () => { @@ -33,7 +36,7 @@ describe('U2FRegister', function () { }); describe('errors', () => { - it('doesn\'t allow the same device to be registered twice (for the same user', () => { + it("doesn't allow the same device to be registered twice (for the same user", () => { const setupButton = this.container.find('#js-setup-u2f-device'); setupButton.trigger('click'); this.u2fDevice.respondToRegisterRequest({ diff --git a/spec/javascripts/u2f/util_spec.js b/spec/javascripts/u2f/util_spec.js index d1a64348da6..32cd6891384 100644 --- a/spec/javascripts/u2f/util_spec.js +++ b/spec/javascripts/u2f/util_spec.js @@ -3,49 +3,57 @@ import { canInjectU2fApi } from '~/u2f/util'; describe('U2F Utils', () => { describe('canInjectU2fApi', () => { it('returns false for Chrome < 41', () => { - const userAgent = 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.28 Safari/537.36'; + const userAgent = + 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.28 Safari/537.36'; expect(canInjectU2fApi(userAgent)).toBe(false); }); it('returns true for Chrome >= 41', () => { - const userAgent = 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36'; + const userAgent = + 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36'; expect(canInjectU2fApi(userAgent)).toBe(true); }); it('returns false for Opera < 40', () => { - const userAgent = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36 OPR/32.0.1948.25'; + const userAgent = + 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36 OPR/32.0.1948.25'; expect(canInjectU2fApi(userAgent)).toBe(false); }); it('returns true for Opera >= 40', () => { - const userAgent = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36 OPR/43.0.2442.991'; + const userAgent = + 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36 OPR/43.0.2442.991'; expect(canInjectU2fApi(userAgent)).toBe(true); }); it('returns false for Safari', () => { - const userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.1.1 Safari/603.2.4'; + const userAgent = + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.1.1 Safari/603.2.4'; expect(canInjectU2fApi(userAgent)).toBe(false); }); it('returns false for Chrome on Android', () => { - const userAgent = 'Mozilla/5.0 (Linux; Android 7.0; VS988 Build/NRD90U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3145.0 Mobile Safari/537.36'; + const userAgent = + 'Mozilla/5.0 (Linux; Android 7.0; VS988 Build/NRD90U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3145.0 Mobile Safari/537.36'; expect(canInjectU2fApi(userAgent)).toBe(false); }); it('returns false for Chrome on iOS', () => { - const userAgent = 'Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) CriOS/56.0.2924.75 Mobile/14E5239e Safari/602.1'; + const userAgent = + 'Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) CriOS/56.0.2924.75 Mobile/14E5239e Safari/602.1'; expect(canInjectU2fApi(userAgent)).toBe(false); }); it('returns false for Safari on iOS', () => { - const userAgent = 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A356 Safari/604.1'; + const userAgent = + 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A356 Safari/604.1'; expect(canInjectU2fApi(userAgent)).toBe(false); }); |