Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const transformTest = function(actual, expected) {
if (expected.error) {
let transformError;
try {
testTransform(actual);
} catch (error) {
transformError = error;
}
expect(transformError.toString()).toContain(expected.error.message);
expect(transformError.loc).toEqual(expected.error.loc);
} else if (expected.output) {
const output = testTransform(actual);
if (expected.output.code !== undefined) {
const normalizedActual = output && output.code && stripIndents(output.code);
const normalizedExpected = stripIndents(expected.output.code);
if (normalizedActual !== normalizedExpected) {
// we should fail, but with style
expect(prettier.format(normalizedActual, { parser: 'babel' })).toBe(
prettier.format(normalizedExpected, { parser: 'babel' })
);
} else {
expect(normalizedActual).toBe(normalizedExpected);
}
}
} else {
throw new TypeError(`Transform test expect an object with either error or output.`);
}
};
if (expected.error) {
let transformError;
try {
testTransform(actual);
} catch (error) {
transformError = error;
}
expect(transformError.toString()).toContain(expected.error.message);
expect(transformError.loc).toEqual(expected.error.loc);
} else if (expected.output) {
const output = testTransform(actual);
if (expected.output.code !== undefined) {
const normalizedActual = output && output.code && stripIndents(output.code);
const normalizedExpected = stripIndents(expected.output.code);
if (normalizedActual !== normalizedExpected) {
// we should fail, but with style
expect(prettier.format(normalizedActual, { parser: 'babel' })).toBe(
prettier.format(normalizedExpected, { parser: 'babel' })
);
} else {
expect(normalizedActual).toBe(normalizedExpected);
}
}
} else {
throw new TypeError(`Transform test expect an object with either error or output.`);
}
};
borderRadius = '100%'
break
case 'squircle':
borderRadius = '8px'
break
case 'rounded-square':
borderRadius = '4px'
break
case 'square':
borderRadius = '0'
break
default:
throw new Error(`Unsupported type: ${type}`)
}
let styleText = stripIndents(oneLine)`
#${id} {
background-color: ${invert ? '#fff' : '#6262F6'};
color: ${invert ? '#6262F6' : '#fff'};
border-radius: ${borderRadius};
text-decoration: none;
display: inline-flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
height: 34px;
width: 34px;
}
#${id}-logo {
width: 20px;
}
display: flex;
width: 100%;
align-items: center;
justify-content: center;
margin-left: 12px;
margin-right: 12px;
}
#${id}-logo {
margin-right: 6px;
height: 22px;
}
`
if (['sign-up', 'log-in', 'verify'].indexOf(type) >= 0) {
styleText += stripIndents(oneLine)`
#${id}-text {
margin-top: 2px;
}
`
}
style.append(styleText)
return style
}
function add (msg) {
formatted.push(stripIndents(msg))
}
#${id}-text-and-logo {
display: flex;
width: 100%;
align-items: center;
justify-content: center;
}
#${id}-logo {
margin-right: 4px;
height: 16px;
}
`
if (['sign-up', 'log-in', 'verify'].indexOf(type) >= 0) {
styleText += stripIndents(oneLine)`
#${id}-text {
margin-top: 2px;
}
`
}
style.append(styleText)
return style
}