-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #870 from neet/multiple-accounts
E2E test using multiple accounts
- Loading branch information
Showing
106 changed files
with
2,251 additions
and
405 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
comment: false | ||
|
||
flag_management: | ||
default_rules: | ||
carryforward: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './http-mock-impl'; | ||
export * from './ws-mock-impl'; | ||
export * from './logger-mock-impl'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { BaseLogger } from '../logger'; | ||
|
||
export const log = jest.fn(); | ||
|
||
export class LoggerMockImpl extends BaseLogger { | ||
log = log; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
import { createHttpError } from './factory'; | ||
import { MastoHttpConflictError } from './masto-http-conflict-error'; | ||
import { MastoHttpForbiddenError } from './masto-http-forbidden-error'; | ||
import { MastoHttpGoneError } from './masto-http-gone-error'; | ||
import { MastoHttpNotFoundError } from './masto-http-not-found-error'; | ||
import { MastoHttpRateLimitError } from './masto-http-rate-limit-error'; | ||
import { MastoHttpUnauthorizedError } from './masto-http-unauthorized-error'; | ||
import { MastoHttpUnexpectedError } from './masto-http-unexpected-error'; | ||
import { MastoHttpUnprocessableEntityError } from './masto-http-unprocessable-entity-error'; | ||
|
||
describe('HTTP error factory', () => { | ||
it('creates unauthorized error', () => { | ||
const cause = {}; | ||
const error = createHttpError({ | ||
statusCode: 401, | ||
message: 'Unauthorized', | ||
cause, | ||
}); | ||
|
||
expect(error).toBeInstanceOf(MastoHttpUnauthorizedError); | ||
expect(error.cause).toBe(cause); | ||
expect(error.message).toBe('Unauthorized'); | ||
}); | ||
|
||
it('creates forbidden error', () => { | ||
const cause = {}; | ||
const error = createHttpError({ | ||
statusCode: 403, | ||
message: 'Forbidden', | ||
cause, | ||
}); | ||
|
||
expect(error).toBeInstanceOf(MastoHttpForbiddenError); | ||
expect(error.cause).toBe(cause); | ||
expect(error.message).toBe('Forbidden'); | ||
}); | ||
|
||
it('creates not found error', () => { | ||
const cause = {}; | ||
const error = createHttpError({ | ||
statusCode: 404, | ||
message: 'Not Found', | ||
cause, | ||
}); | ||
|
||
expect(error).toBeInstanceOf(MastoHttpNotFoundError); | ||
expect(error.cause).toBe(cause); | ||
expect(error.message).toBe('Not Found'); | ||
}); | ||
|
||
it('creates conflict error', () => { | ||
const cause = {}; | ||
const error = createHttpError({ | ||
statusCode: 409, | ||
message: 'Conflict', | ||
cause, | ||
}); | ||
|
||
expect(error).toBeInstanceOf(MastoHttpConflictError); | ||
expect(error.cause).toBe(cause); | ||
expect(error.message).toBe('Conflict'); | ||
}); | ||
|
||
it('creates gone error', () => { | ||
const cause = {}; | ||
const error = createHttpError({ | ||
statusCode: 410, | ||
message: 'Gone', | ||
cause, | ||
}); | ||
|
||
expect(error).toBeInstanceOf(MastoHttpGoneError); | ||
expect(error.cause).toBe(cause); | ||
expect(error.message).toBe('Gone'); | ||
}); | ||
|
||
it('creates unprocessable entity error', () => { | ||
const cause = {}; | ||
const error = createHttpError({ | ||
statusCode: 422, | ||
message: 'Unprocessable Entity', | ||
cause, | ||
}); | ||
|
||
expect(error).toBeInstanceOf(MastoHttpUnprocessableEntityError); | ||
expect(error.cause).toBe(cause); | ||
expect(error.message).toBe('Unprocessable Entity'); | ||
}); | ||
|
||
it('creates rate limit error', () => { | ||
const cause = {}; | ||
const error = createHttpError({ | ||
statusCode: 429, | ||
message: 'Rate Limit Exceeded', | ||
cause, | ||
limit: 100, | ||
remaining: 0, | ||
reset: '2021-01-01T00:00:00.000Z', | ||
}); | ||
|
||
expect(error).toBeInstanceOf(MastoHttpRateLimitError); | ||
expect(error.cause).toBe(cause); | ||
expect(error.message).toBe('Rate Limit Exceeded'); | ||
}); | ||
|
||
it('creates unexpected error', () => { | ||
const cause = {}; | ||
const error = createHttpError({ | ||
statusCode: 500, | ||
message: 'Internal Server Error', | ||
cause, | ||
}); | ||
|
||
expect(error).toBeInstanceOf(MastoHttpUnexpectedError); | ||
expect(error.cause).toBe(cause); | ||
expect(error.message).toBe('Internal Server Error'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { MastoUnexpectedError } from './masto-unexpected-error'; | ||
|
||
it('constructs', () => { | ||
const error = new MastoUnexpectedError('foo'); | ||
expect(error.message).toBe('foo'); | ||
expect(error.name).toBe('MastoUnexpectedError'); | ||
expect(error.stack).toBeDefined(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { MastoVersionError } from './masto-version-error'; | ||
|
||
it('constructs', () => { | ||
const error = new MastoVersionError('foo'); | ||
expect(error.message).toBe('foo'); | ||
expect(error.name).toBe('MastoVersionError'); | ||
expect(error.stack).toBeDefined(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
/* eslint-disable unicorn/no-useless-undefined */ | ||
import { log, LoggerMockImpl } from '../__mocks__'; | ||
import { LogLevel } from './log-level'; | ||
|
||
describe('debug', () => { | ||
const level = LogLevel.from('debug'); | ||
|
||
afterEach(() => { | ||
log.mockClear(); | ||
}); | ||
|
||
test('debug', () => { | ||
const logger = new LoggerMockImpl(level); | ||
logger.debug('message'); | ||
expect(log).toBeCalledWith('debug', 'message', undefined); | ||
}); | ||
|
||
test('info', () => { | ||
const logger = new LoggerMockImpl(level); | ||
logger.info('message'); | ||
expect(log).toBeCalledWith('info', 'message', undefined); | ||
}); | ||
|
||
test('warn', () => { | ||
const logger = new LoggerMockImpl(level); | ||
logger.warn('message'); | ||
expect(log).toBeCalledWith('warn', 'message', undefined); | ||
}); | ||
|
||
test('error', () => { | ||
const logger = new LoggerMockImpl(level); | ||
logger.error('message'); | ||
expect(log).toBeCalledWith('error', 'message', undefined); | ||
}); | ||
}); | ||
|
||
describe('info', () => { | ||
const level = LogLevel.from('info'); | ||
|
||
afterEach(() => { | ||
log.mockClear(); | ||
}); | ||
|
||
test('debug', () => { | ||
const logger = new LoggerMockImpl(level); | ||
logger.debug('message'); | ||
expect(log).not.toBeCalledWith('debug', 'message', undefined); | ||
}); | ||
|
||
test('info', () => { | ||
const logger = new LoggerMockImpl(level); | ||
logger.info('message'); | ||
expect(log).toBeCalledWith('info', 'message', undefined); | ||
}); | ||
|
||
test('warn', () => { | ||
const logger = new LoggerMockImpl(level); | ||
logger.warn('message'); | ||
expect(log).toBeCalledWith('warn', 'message', undefined); | ||
}); | ||
|
||
test('error', () => { | ||
const logger = new LoggerMockImpl(level); | ||
logger.error('message'); | ||
expect(log).toBeCalledWith('error', 'message', undefined); | ||
}); | ||
}); | ||
|
||
describe('warn', () => { | ||
const level = LogLevel.from('warn'); | ||
|
||
afterEach(() => { | ||
log.mockClear(); | ||
}); | ||
|
||
test('debug', () => { | ||
const logger = new LoggerMockImpl(level); | ||
logger.debug('message'); | ||
expect(log).not.toBeCalledWith('debug', 'message', undefined); | ||
}); | ||
|
||
test('info', () => { | ||
const logger = new LoggerMockImpl(level); | ||
logger.info('message'); | ||
expect(log).not.toBeCalledWith('info', 'message', undefined); | ||
}); | ||
|
||
test('warn', () => { | ||
const logger = new LoggerMockImpl(level); | ||
logger.warn('message'); | ||
expect(log).toBeCalledWith('warn', 'message', undefined); | ||
}); | ||
|
||
test('error', () => { | ||
const logger = new LoggerMockImpl(level); | ||
logger.error('message'); | ||
expect(log).toBeCalledWith('error', 'message', undefined); | ||
}); | ||
}); | ||
|
||
describe('error', () => { | ||
const level = LogLevel.from('error'); | ||
|
||
afterEach(() => { | ||
log.mockClear(); | ||
}); | ||
|
||
test('debug', () => { | ||
const logger = new LoggerMockImpl(level); | ||
logger.debug('message'); | ||
expect(log).not.toBeCalledWith('debug', 'message', undefined); | ||
}); | ||
|
||
test('info', () => { | ||
const logger = new LoggerMockImpl(level); | ||
logger.info('message'); | ||
expect(log).not.toBeCalledWith('info', 'message', undefined); | ||
}); | ||
|
||
test('warn', () => { | ||
const logger = new LoggerMockImpl(level); | ||
logger.warn('message'); | ||
expect(log).not.toBeCalledWith('warn', 'message', undefined); | ||
}); | ||
|
||
test('error', () => { | ||
const logger = new LoggerMockImpl(level); | ||
logger.error('message'); | ||
expect(log).toBeCalledWith('error', 'message', undefined); | ||
}); | ||
}); |
Oops, something went wrong.