|
14 | 14 | * See the License for the specific language governing permissions and |
15 | 15 | * limitations under the License. |
16 | 16 | */ |
17 | | -import { resolveCdnUrl, resolveHost, removeEmpty, uniqueTime, uniqueId, md5, sanitizeName, filterObject, b64, getVersion, cleanUpCallbacks } from './index'; |
| 17 | +import { resolveCdnUrl, resolveHost, removeEmpty, uniqueTime, uniqueId, md5, extensionToMime, sanitizeName, filterObject, b64, getVersion, cleanUpCallbacks } from './index'; |
18 | 18 | import { config } from '../../config'; |
19 | 19 | const v = require('../../../../package.json').version; |
20 | 20 |
|
@@ -182,6 +182,34 @@ describe('utils:index', () => { |
182 | 182 | }); |
183 | 183 | }); |
184 | 184 |
|
| 185 | + describe('extensionToMime', () => { |
| 186 | + it('should return mimetype if mime is passed', () => { |
| 187 | + expect(extensionToMime('')).toEqual(undefined); |
| 188 | + }); |
| 189 | + |
| 190 | + it('should return same mime is passed', () => { |
| 191 | + expect(extensionToMime('image/png')).toEqual('image/png'); |
| 192 | + expect(extensionToMime('image/jpg')).toEqual('image/jpg'); |
| 193 | + expect(extensionToMime('application/pdf')).toEqual('application/pdf'); |
| 194 | + }); |
| 195 | + |
| 196 | + it('it should return correct mimes for ext', () => { |
| 197 | + expect(extensionToMime('.png')).toEqual('image/png'); |
| 198 | + expect(extensionToMime('.jpg')).toEqual('image/jpeg'); |
| 199 | + expect(extensionToMime('.pdf')).toEqual('application/pdf'); |
| 200 | + |
| 201 | + expect(extensionToMime('.key')).toEqual('application/vnd.apple.keynote'); |
| 202 | + expect(extensionToMime('.zip')).toEqual('application/zip'); |
| 203 | + expect(extensionToMime('.numbers')).toEqual('application/vnd.apple.numbers'); |
| 204 | + }); |
| 205 | + |
| 206 | + it('it should extract extensions form filename or ext with dot', () => { |
| 207 | + expect(extensionToMime('test.png')).toEqual('image/png'); |
| 208 | + expect(extensionToMime('test.jpg')).toEqual('image/jpeg'); |
| 209 | + expect(extensionToMime('test.pdf')).toEqual('application/pdf'); |
| 210 | + }); |
| 211 | + }); |
| 212 | + |
185 | 213 | describe('CleanupCallbacks', () => { |
186 | 214 | it('should set callbacks as undefined and return untouched object', () => { |
187 | 215 | const testObj = { |
|
0 commit comments