2020-05-24 23:13:21 +05:30
import { GlSprintf } from '@gitlab/ui' ;
2021-03-11 19:13:27 +05:30
import { shallowMount } from '@vue/test-utils' ;
2020-10-24 23:57:45 +05:30
import BlobContentError from '~/blob/components/blob_content_error.vue' ;
2020-05-24 23:13:21 +05:30
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 `
2020-07-28 23:09:34 +05:30
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 10.00 MiB' } | $ { [ BLOB _RENDER _ERRORS . OPTIONS . DOWNLOAD . text ] }
2020-05-24 23:13:21 +05:30
` ('renders correct reason for $ error.id', ({ error, reason, options }) => {
createComponent ( {
viewerError : error . id ,
} ) ;
expect ( wrapper . text ( ) ) . toContain ( reason ) ;
2021-03-08 18:12:59 +05:30
options . forEach ( ( option ) => {
2020-05-24 23:13:21 +05:30
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 ) ;
2021-03-08 18:12:59 +05:30
options . forEach ( ( option ) => {
2020-05-24 23:13:21 +05:30
expect ( wrapper . text ( ) ) . toContain ( option ) ;
} ) ;
} ) ;
2020-03-13 15:44:24 +05:30
} ) ;
} ) ;