2020-03-13 15:44:24 +05:30
import { shallowMount } from '@vue/test-utils' ;
import BlobContentError from '~/blob/components/blob_content_error.vue' ;
2020-05-24 23:13:21 +05:30
import { GlSprintf } from '@gitlab/ui' ;
import { BLOB _RENDER _ERRORS } from '~/blob/components/constants' ;
2020-03-13 15:44:24 +05:30
describe ( 'Blob Content Error component' , ( ) => {
let wrapper ;
2020-05-24 23:13:21 +05:30
function createComponent ( props = { } ) {
2020-03-13 15:44:24 +05:30
wrapper = shallowMount ( BlobContentError , {
propsData : {
2020-05-24 23:13:21 +05:30
... props ,
} ,
stubs : {
GlSprintf ,
2020-03-13 15:44:24 +05:30
} ,
} ) ;
}
afterEach ( ( ) => {
wrapper . destroy ( ) ;
} ) ;
2020-05-24 23:13:21 +05:30
describe ( 'collapsed and too large blobs' , ( ) => {
it . each `
error | reason | options
$ { BLOB _RENDER _ERRORS . REASONS . COLLAPSED } | $ { 'it is larger than 1.00 MiB' } | $ { [ BLOB _RENDER _ERRORS . OPTIONS . LOAD . text , BLOB _RENDER _ERRORS . OPTIONS . DOWNLOAD . text ] }
$ { BLOB _RENDER _ERRORS . REASONS . TOO _LARGE } | $ { 'it is larger than 100.00 MiB' } | $ { [ BLOB _RENDER _ERRORS . OPTIONS . DOWNLOAD . text ] }
` ('renders correct reason for $ error.id', ({ error, reason, options }) => {
createComponent ( {
viewerError : error . id ,
} ) ;
expect ( wrapper . text ( ) ) . toContain ( reason ) ;
options . forEach ( option => {
expect ( wrapper . text ( ) ) . toContain ( option ) ;
} ) ;
} ) ;
} ) ;
describe ( 'external blob' , ( ) => {
it . each `
storageType | reason | options
$ { 'lfs' } | $ { BLOB _RENDER _ERRORS . REASONS . EXTERNAL . text . lfs } | $ { [ BLOB _RENDER _ERRORS . OPTIONS . DOWNLOAD . text ] }
$ { 'build_artifact' } | $ { BLOB _RENDER _ERRORS . REASONS . EXTERNAL . text . build _artifact } | $ { [ BLOB _RENDER _ERRORS . OPTIONS . DOWNLOAD . text ] }
$ { 'default' } | $ { BLOB _RENDER _ERRORS . REASONS . EXTERNAL . text . default } | $ { [ BLOB _RENDER _ERRORS . OPTIONS . DOWNLOAD . text ] }
` ('renders correct reason for $ storageType blob', ({ storageType, reason, options }) => {
createComponent ( {
viewerError : BLOB _RENDER _ERRORS . REASONS . EXTERNAL . id ,
blob : {
externalStorage : storageType ,
} ,
} ) ;
expect ( wrapper . text ( ) ) . toContain ( reason ) ;
options . forEach ( option => {
expect ( wrapper . text ( ) ) . toContain ( option ) ;
} ) ;
} ) ;
2020-03-13 15:44:24 +05:30
} ) ;
} ) ;