Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test('render non-breaking', () => {
const change: Change = {
criticality: {
level: CriticalityLevel.NonBreaking,
},
type: ChangeType.TypeRemoved,
message: 'Chill, non breaking',
path: 'Type.field',
};
const [symbol, msg] = renderChange(change);
expect(symbol).toBeDefined();
expect(symbol).toEqual(getSymbol(CriticalityLevel.NonBreaking));
expect(msg).toBeDefined();
expect(msg).toEqual(change.message);
});
test('render non-breaking', () => {
const change: Change = {
criticality: {
level: CriticalityLevel.NonBreaking,
},
type: ChangeType.TypeRemoved,
message: 'Chill, non breaking',
path: 'Type.field',
};
const [symbol, msg] = renderChange(change);
expect(symbol).toBeDefined();
expect(symbol).toEqual(getSymbol(CriticalityLevel.NonBreaking));
expect(msg).toBeDefined();
expect(msg).toEqual(change.message);
});
function getSymbol(level: CriticalityLevel): string {
const symbols = {
[CriticalityLevel.Dangerous]: logSymbols.warning,
[CriticalityLevel.Breaking]: logSymbols.error,
[CriticalityLevel.NonBreaking]: logSymbols.success
};
return symbols[level];
}
change => change.criticality.level === CriticalityLevel.Breaking,
)
) {
conclusion = CheckConclusion.Failure;
}
return {
conclusion,
annotations,
};
}
const levelMap = {
[CriticalityLevel.Breaking]: AnnotationLevel.Failure,
[CriticalityLevel.Dangerous]: AnnotationLevel.Warning,
[CriticalityLevel.NonBreaking]: AnnotationLevel.Notice,
};
function annotate({
path,
change,
schemas,
}: {
path: string;
change: Change;
schemas: {
old: GraphQLSchema;
new: GraphQLSchema;
};
}): Annotation {
const level = change.criticality.level;
const schema = change.type.endsWith('_REMOVED') ? schemas.old : schemas.new;
export function getSymbol(level: CriticalityLevel): string {
const symbols = {
[CriticalityLevel.Dangerous]: logSymbols.warning,
[CriticalityLevel.Breaking]: logSymbols.error,
[CriticalityLevel.NonBreaking]: logSymbols.success,
};
return symbols[level];
}