mirror of
https://github.com/cypress-io/cypress.git
synced 2026-05-03 05:20:38 -05:00
91fe08e57e
* chore: rework vitest mocks * chore: turn on ANSI for snapshots in the CLI * chore: remove check-more-types from the CLI and just use lodash/regex * chore: remove lazy-ass in favor of the native assertion library in node
47 lines
1.0 KiB
TypeScript
47 lines
1.0 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import assert from 'assert'
|
|
import { stripIndent, stripIndents } from 'common-tags'
|
|
|
|
describe('stripIndent', () => {
|
|
it('removes indent from literal string', () => {
|
|
const removed = stripIndent`
|
|
first line
|
|
second line
|
|
third line
|
|
last line
|
|
`
|
|
|
|
// should preserve the structure of the text
|
|
expect(removed).toMatchSnapshot()
|
|
})
|
|
|
|
it('can be called as a function', () => {
|
|
const text = ' foo\n bar\n'
|
|
const removed = stripIndent(text)
|
|
// removed 1 level of indentation and trimmed the string
|
|
const expected = 'foo\n bar'
|
|
|
|
assert.ok(removed === expected, `removed indent is\n${removed}`)
|
|
})
|
|
|
|
it('can be used with nested message', () => {
|
|
const nested = stripIndents(' foo\n bar\n')
|
|
const str = stripIndents`
|
|
first line
|
|
|
|
${nested}
|
|
|
|
last line
|
|
`
|
|
|
|
// should have NO indents
|
|
// first line
|
|
//
|
|
// foo
|
|
// bar
|
|
//
|
|
// last line
|
|
expect(str).toMatchSnapshot()
|
|
})
|
|
})
|