-
Notifications
You must be signed in to change notification settings - Fork 578
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fc7a9d9
commit a631b90
Showing
61 changed files
with
417 additions
and
228 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 was deleted.
Oops, something went wrong.
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,7 +1,4 @@ | ||
// jest.config.js | ||
const base = require('./jest.config.base.js') | ||
|
||
/** @type {import('jest').Config} */ | ||
module.exports = { | ||
...base, | ||
projects: ['<rootDir>/packages/*/jest.config.js'], | ||
} |
File renamed without changes.
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,6 +1,9 @@ | ||
const base = require('../../jest.config.base.js') | ||
|
||
/** @type {import('jest').Config} */ | ||
module.exports = { | ||
...base, | ||
displayName: 'API', | ||
transform: { '^.+\\.(t|j)s$': '@swc/jest' }, | ||
transformIgnorePatterns: [`<rootDir>/node_modules/(?!get-port)`], | ||
testTimeout: 60000, | ||
setupFiles: ['<rootDir>/../../jest.setup.ts'], | ||
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'], | ||
} |
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,20 @@ | ||
declare namespace jest { | ||
// eslint-disable-next-line | ||
interface Matchers<R, T = {}> { | ||
toBeModerationResult( | ||
expected: ModerationBehaviorResult | undefined, | ||
context: string, | ||
stringifiedResult: string, | ||
ignoreCause?: boolean, | ||
): R | ||
} | ||
|
||
interface Expect { | ||
toBeModerationResult( | ||
expected: ModerationBehaviorResult | undefined, | ||
context: string, | ||
stringifiedResult: string, | ||
ignoreCause?: boolean, | ||
): void | ||
} | ||
} |
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,79 @@ | ||
import { ModerationBehaviorResult } from './definitions/moderation-behaviors' | ||
import { ModerationUI } from './src' | ||
|
||
expect.extend({ | ||
toBeModerationResult( | ||
actual: ModerationUI, | ||
expected: ModerationBehaviorResult | undefined, | ||
context: string, | ||
stringifiedResult: string, | ||
ignoreCause = false, | ||
) { | ||
const fail = (msg: string) => ({ | ||
pass: false, | ||
message: () => `${msg}. Full result: ${stringifiedResult}`, | ||
}) | ||
let cause = actual.cause?.type as string | ||
if (actual.cause?.type === 'label') { | ||
cause = `label:${actual.cause.labelDef.id}` | ||
} else if (actual.cause?.type === 'muted') { | ||
if (actual.cause.source.type === 'list') { | ||
cause = 'muted-by-list' | ||
} | ||
} else if (actual.cause?.type === 'blocking') { | ||
if (actual.cause.source.type === 'list') { | ||
cause = 'blocking-by-list' | ||
} | ||
} | ||
if (!expected) { | ||
if (!ignoreCause && actual.cause) { | ||
return fail(`${context} expected to be a no-op, got ${cause}`) | ||
} | ||
if (actual.alert) { | ||
return fail(`${context} expected to be a no-op, got alert=true`) | ||
} | ||
if (actual.blur) { | ||
return fail(`${context} expected to be a no-op, got blur=true`) | ||
} | ||
if (actual.filter) { | ||
return fail(`${context} expected to be a no-op, got filter=true`) | ||
} | ||
if (actual.noOverride) { | ||
return fail(`${context} expected to be a no-op, got noOverride=true`) | ||
} | ||
} else { | ||
if (!ignoreCause && cause !== expected.cause) { | ||
return fail(`${context} expected to be ${expected.cause}, got ${cause}`) | ||
} | ||
if (!!actual.alert !== !!expected.alert) { | ||
return fail( | ||
`${context} expected to be alert=${expected.alert || false}, got ${ | ||
actual.alert || false | ||
}`, | ||
) | ||
} | ||
if (!!actual.blur !== !!expected.blur) { | ||
return fail( | ||
`${context} expected to be blur=${expected.blur || false}, got ${ | ||
actual.blur || false | ||
}`, | ||
) | ||
} | ||
if (!!actual.filter !== !!expected.filter) { | ||
return fail( | ||
`${context} expected to be filter=${expected.filter || false}, got ${ | ||
actual.filter || false | ||
}`, | ||
) | ||
} | ||
if (!!actual.noOverride !== !!expected.noOverride) { | ||
return fail( | ||
`${context} expected to be noOverride=${ | ||
expected.noOverride || false | ||
}, got ${actual.noOverride || false}`, | ||
) | ||
} | ||
} | ||
return { pass: true, message: () => '' } | ||
}, | ||
}) |
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
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,7 +1,4 @@ | ||
{ | ||
"include": [], | ||
"references": [ | ||
{ "path": "./tsconfig.build.json" }, | ||
{ "path": "./tsconfig.tests.json" } | ||
] | ||
"references": [{ "path": "./tsconfig.build.json" }] | ||
} |
This file was deleted.
Oops, something went wrong.
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,6 +1,8 @@ | ||
const base = require('../../jest.config.base.js') | ||
|
||
/** @type {import('jest').Config} */ | ||
module.exports = { | ||
...base, | ||
displayName: 'Bsky App View', | ||
transform: { '^.+\\.(t|j)s$': '@swc/jest' }, | ||
transformIgnorePatterns: [`<rootDir>/node_modules/(?!get-port)`], | ||
testTimeout: 60000, | ||
setupFiles: ['<rootDir>/../../jest.setup.ts'], | ||
} |
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 |
---|---|---|
|
@@ -75,6 +75,7 @@ | |
"@types/pg": "^8.6.6", | ||
"@types/qs": "^6.9.7", | ||
"axios": "^0.27.2", | ||
"jest": "^28.1.2", | ||
"ts-node": "^10.8.2" | ||
} | ||
} |
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
Oops, something went wrong.